<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<%@ taglib prefix="custom" tagdir="/WEB-INF/tags" %>
<html>
<body>
<form:form commandName="formDto" id="form">
    <input type="hidden" name="MemberUuid" id="MemberUuid">

    <div class="modal-header">
        <h4 class="modal-title" id="myModalLabel">
            微信解绑
        </h4>
    </div>
    <div class="modal-body">
        <c:if test="${not empty formDto.memberDtoList}">
            <div class="form-group">
                <div class="col-sm-12">
                    <c:forEach items="${formDto.memberDtoList}" var="m">
                        <button type="button" class="btn btn-primary employeeItem"
                                uuid="${m.uuid}">
                                ${m.nickname}
                        </button>
                    </c:forEach><br/>
                    <span class="error text-danger ErrorText"></span>
                </div>
            </div>
        </c:if>
    </div>
    <div class="modal-footer">
        <button type="button" class="btn btn-primary" id="SubmitBtn">
            确定
        </button>
        <button type="button" class="btn btn-default" data-dismiss="modal">关闭
        </button>
    </div>
</form:form>
<style type="text/css">
    .deptItem, .employeeItem {
        margin: 3px 0;
    }
</style>
<script type="text/javascript">
    $("#SubmitBtn").click(function () {
        var serialize = $("#form").serialize();
        $.ajax({
            url: 'relieve_member',
            data: serialize,
            type: 'post',
            cache: false,
            success: function (data) {
                if (data.state) {
                    window.location.reload();
                } else {
                    $(".ErrorText").html(data.msg);
                }
            },
            error: function () {
                alert("失败");
            }
        });
    });
    $(".employeeItem").click(function () {
        $(this).siblings().removeClass("btn-success");
        $(this).addClass("btn-success");
        $("#MemberUuid").val($(this).attr("uuid"));
    });
</script>
</body>
</html>
